home *** CD-ROM | disk | FTP | other *** search
- /* free.c
- Finds free space on a disk drive
-
- Invocation:
-
- free <drive>
- where <drive> is a valid drive descriptor.
-
- */
-
- #include "ctype.h"
- #include "stdio.h"
-
- main(argc,argv)
-
- int argc;
- char *argv[];
-
- {
-
- char drive;
- long space,kbytes;
- int driveno,clusters;
-
- if (argc-2)
- {
- printf(" Invalid command line format\n");
- printf(" Invoke with free <drive letter>\n");
- exit(1);
- }
-
- else
- {
- drive = toupper(*argv[1]); /* get drive letter */
- driveno = (int)((drive)-'A'+1);
- space = free_sectors(driveno); /* print free space */
- if (space == -1) {
- printf("Invalid drive letter\n");
- exit(1);
- }
- else
- printf( "\nDrive %c has %ld sectors remaining\n",drive,space);
- clusters = free_clusters(driveno);
- printf(" %d clusters\n",clusters);
- kbytes = free_kbytes(driveno);
- printf(" %ld Kbytes\n",kbytes);
- }
- }
-
- free_sectors(des)
-
- int des;
-
- {
-
- long freesec;
-
- freesec = get_disk_free_space(des);
- return(freesec);
-
- }
-
- get_disk_free_space(driveno)
-
- int driveno;
-
- {
-
- #asm
-
- mov dx,[bp+8]
- mov ah,36h
- int 21h
- cmp ax,-1
- je gdfs0
- mul bx
- jmp short gdfsx
-
- gdfs0:
- mov dx,-1
- gdfsx:
-
- #endasm
-
- }
-
- free_clusters(driveno)
-
- int driveno;
-
- {
-
- #asm
- mov dx,[bp+8]
- mov ah,36h
- int 21h
- mov ax,bx
- #endasm
-
- }
-
- free_kbytes(driveno)
-
- int driveno;
-
- {
-
- #asm
-
- mov dx,[bp+8]
- mov ah,36h
- int 21h
- mul bx
- mov bx,2
- idiv bx
-
- #endasm
-
- }